Make a standalone hello world
authorMatthias Clasen <mclasen@redhat.com>
Tue, 8 Jun 2021 21:26:36 +0000 (17:26 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 8 Jun 2021 21:41:11 +0000 (17:41 -0400)
We want to test building against the installed GTK
in ci, so lets add a standalone project.

examples/hello-world.c [deleted file]
examples/hello/hello-world.c [new file with mode: 0644]
examples/hello/meson.build [new file with mode: 0644]
examples/meson.build

diff --git a/examples/hello-world.c b/examples/hello-world.c
deleted file mode 100644 (file)
index f4c058e..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <gtk/gtk.h>
-
-static void
-print_hello (GtkWidget *widget,
-             gpointer   data)
-{
-  g_print ("Hello World\n");
-}
-
-static void
-activate (GtkApplication *app,
-          gpointer        user_data)
-{
-  GtkWidget *window;
-  GtkWidget *button;
-  GtkWidget *box;
-
-  window = gtk_application_window_new (app);
-  gtk_window_set_title (GTK_WINDOW (window), "Window");
-  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
-
-  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-  gtk_window_set_child (GTK_WINDOW (window), box);
-
-  button = gtk_button_new_with_label ("Hello World");
-  g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
-  g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
-  gtk_box_append (GTK_BOX (box), button);
-
-  gtk_widget_show (window);
-}
-
-int
-main (int    argc,
-      char **argv)
-{
-  GtkApplication *app;
-  int status;
-
-  app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
-  g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
-  status = g_application_run (G_APPLICATION (app), argc, argv);
-  g_object_unref (app);
-
-  return status;
-}
diff --git a/examples/hello/hello-world.c b/examples/hello/hello-world.c
new file mode 100644 (file)
index 0000000..f4c058e
--- /dev/null
@@ -0,0 +1,46 @@
+#include <gtk/gtk.h>
+
+static void
+print_hello (GtkWidget *widget,
+             gpointer   data)
+{
+  g_print ("Hello World\n");
+}
+
+static void
+activate (GtkApplication *app,
+          gpointer        user_data)
+{
+  GtkWidget *window;
+  GtkWidget *button;
+  GtkWidget *box;
+
+  window = gtk_application_window_new (app);
+  gtk_window_set_title (GTK_WINDOW (window), "Window");
+  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
+
+  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+  gtk_window_set_child (GTK_WINDOW (window), box);
+
+  button = gtk_button_new_with_label ("Hello World");
+  g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
+  g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
+  gtk_box_append (GTK_BOX (box), button);
+
+  gtk_widget_show (window);
+}
+
+int
+main (int    argc,
+      char **argv)
+{
+  GtkApplication *app;
+  int status;
+
+  app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
+  g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
+  status = g_application_run (G_APPLICATION (app), argc, argv);
+  g_object_unref (app);
+
+  return status;
+}
diff --git a/examples/hello/meson.build b/examples/hello/meson.build
new file mode 100644 (file)
index 0000000..bd4cdd5
--- /dev/null
@@ -0,0 +1,10 @@
+project('hello', 'c',
+          version: '4.3.0',
+          meson_version: '>= 0.50.0',
+)
+
+executable('hello',
+  [ 'hello-world.c' ],
+  dependencies: [ dependency('gtk4') ],
+  install: false
+)
index 22e74f34d41854482cd88a39151533bdbb644eb4..ae007bc40402b6d978d211420e43c19e17f3c69d 100644 (file)
@@ -2,7 +2,6 @@ examples = [
   'builder',
   'drawing',
   'grid-packing',
-  'hello-world',
   'plugman',
   'search-bar',
   'sunny',